package com.gitee.minimalismstyle.fresh.common.core.option

import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.type.CollectionType
import com.gitee.minimalismstyle.fresh.common.core.domain.Simple
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component


@Component
class JsonOptions : Options {

    @Autowired
    private lateinit var objectMapper: ObjectMapper

    override fun get(param: Any): List<Simple>{
        val listType: CollectionType = objectMapper.typeFactory.constructCollectionType(ArrayList::class.java, Simple::class.java)
        return objectMapper.readValue(param as String, listType)
    }
}